/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-26 15:04:08
 * @LastEditTime : 2023-05-26 15:05:30
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\EngineeringListMonthPlan.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, SelectExcelButton, OpenExcelButton } from '../Common/options'

import { project } from '../../../Data'
const { hostname } = window.location
const { client_id } = project[hostname]
const out = ['bada', 'jtgj']
export const EngineeringListMonthPlan = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        type: '形象进度',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            !out.includes(client_id) && (
                <SelectExcelButton
                    key="one"
                    title="下载统计信息"
                    OptionsEvent={OptionsEvent}
                    api={API_LIST()['getEngineeringListPlanExcel']}
                />
            ),
            !out.includes(client_id) && (
                <OpenExcelButton
                    key="two"
                    title="批量导入"
                    OptionsEvent={OptionsEvent}
                    data={{
                        save: true,
                        submit: true,
                        url: 'getEngineeringListMonthPlanInfo',
                        pos: 'posUploadEngineeringListPlan',
                    }}
                />
            ),
            Permission?.findIndex(v => v.uuid === '8dad00f6-2bc1-4ba8-b2c1-13c177413d05') !== -1 && (
                <AddDataButton
                    OptionsEvent={OptionsEvent}
                    url={url}
                    type="primary"
                    icon="add"
                    title="新增形象进度月计划"
                />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.SearchSort, selectType: 'EngineeringListMonthPlan' },
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'planType',
                title: '计划类型',
                valueType: 'select',
                valueEnum: { 月份: '月份', 年度: '年度', 总体: '总体' },
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'yearMonth',
                title: '年月',
                valueType: 'Date',
                picker: 'month',
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'engineeringListUuid',
                title: '形象进度',
                valueType: 'select',
                valueEnum: ClientData.engineeringList,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'amount',
                title: '工程量',
                valueType: 'inputNumber',
                rules: true,
                width: 100,
                hideInSearch: true,
            },
            {
                dataIndex: 'unit',
                title: '单位',
                valueType: 'input',
                width: 100,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'remark',
                title: '备注',
                valueType: 'input',
                width: 100,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '26329a79-ca62-40ef-9f10-65ec1ca0bc8e') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '69542ce6-aa1b-4809-8f34-2d3fccdac550') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="delete"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
